//
//  SJDownloader.h
//  dancebaby
//
//  Created by BlueDancer on 2018/4/28.
//  Copyright © 2018年 hunter. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
 自己管理释放时机
 
 当开启一个下载任务时, Downloader 将会在下载期间一直存在, 同Task的生命周期一致
 */
NS_ASSUME_NONNULL_BEGIN
@interface SJDownloader : NSObject
- (void)downloadFileWithURLStr:(NSString *)URLStr
              downloadProgress:(void(^__nullable)(SJDownloader *downloader, float progress))downloadProgressBlock
                       success:(void(^__nullable)(SJDownloader *downloader, NSURL *tmpPath))successBlock
                       failure:(void(^__nullable)(SJDownloader *downloader))failureBlock;

- (void)cancelCompeletion:(void(^__nullable)(SJDownloader *downloader))completion; // 取消下载

@property (nonatomic, strong, nullable, readonly) NSError *error; // 下载出错时赋值

@end
NS_ASSUME_NONNULL_END
